<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <style>
        .box {
            width: 200px;
            height: 150px;
            background-color: #ddd;

            /* 参照物：必须是父元素或者祖先元素 */
            position: relative;
        }

        .box img {
            width: 200px;
            height: 150px;
        }

        .box p {
            width: 200px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            background-color: rgba(0, 0, 0, 0.5);
            /* color: #fff; */

            /* 绝对定位：脱离文档流的  需要参照物，且参照物只能是父元素或者祖先元素   */
            position: absolute;
            left: 0;
            bottom: 0;

            /* height: 0; */
            width: 0;
            /* 文字超出的部分 */
            overflow: hidden;
            transition: 2s;
        }

        /* 摸盒子  p出现 */
        .box:hover p {
            width: 200px;
        }
    </style>
</head>

<body>
    <div class="box">
        <img src="../images/main.jpg" alt="">
        <p>文字呵呵呵呵哈哈哈</p>
    </div>
</body>

</html>